const getters = {
  language: state => state.app.language,
  permission_routers:  state => state.permission.routers,
  addRouters: state => state.permission.addRouters,
  /*
  * 通过userInfo.actions派生出页面按钮的是使用权限
  * 如果actions为空 返回 {}
  * {
  *   pageName: {//页面名字
  *     upload:true,//更新权限
  *     delete:false,//删除数据权限
  *     create:true//创建新数据权限
  *   }
  * }
  *
  *
  * */
  buttonAuthority:(state)=>{
    let getterActions = {};
    if(state.app.userInfo && state.app.userInfo.actions) {
      let _actions = state.app.userInfo.actions;
      _actions.forEach((item) =>{
        let _arr = item.code.split('-');
        if(getterActions.hasOwnProperty(_arr[0])) {
          getterActions[_arr[0]][_arr[1]] = true;
        } else {
          getterActions[_arr[0]] = {};
          getterActions[_arr[0]][_arr[1]] = true;
        }
      })
      return getterActions;
    }else  {
      return getterActions
    }
  }
}
export default getters
